#include <my_header.h>

#include <pthread.h>


void * threadFunc(void * arg)
{

    char *pHeap = (char *)arg;
    printf("I am child thread\n");

    strcpy(pHeap,"world");
    printf("child thread, %s\n",pHeap);


    return NULL;
}
/*验证线程共享堆空间 */
int main(int argc, char *argv[])
{
    ARGS_CHECK(argc,1);

    char *pHeap = (char *)malloc(20);
    strcpy(pHeap,"hello");

    pthread_t tid;
    int ret = pthread_create(&tid,NULL,threadFunc,(void *)pHeap);
    ERROR_CHECK(ret,-1,"pthread_create");

    printf("I am main thread\n");
    sleep(1);

    printf("parent thread, %s\n",pHeap);
    free(pHeap);


    return 0;
}

